#ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H

#include <QWidget>
#include <QPixmap>
#include <QPainter>
#include <QVideoWidget>

#include <QThread>
#include <QImage>
#include <QColor>
#include <QPainter>
#include "ui_rpi_videoWidget.h"


class QTimer;
class QMediaPlayer;
class QMediaPlaylist;
class QNetworkAccessManager;
class QNetworkReply;
class timeConsumingThread : public QThread
{  
   Q_OBJECT

   public:
      timeConsumingThread(QObject *parent = 0);
QNetworkAccessManager *netImageHttp;
public slots:
    void netImageHttpFinished(QNetworkReply* reply);

   signals:
      void theImage(const QPixmap &);

   protected:
      void run();

};

class ImageWindow : public QWidget
{
   Q_OBJECT

   public:
      ImageWindow(QWidget *parent = 0);
      QPixmap plot;

   private:

   protected:
      void paintEvent(QPaintEvent *event);

};



class VideoWidget : public QVideoWidget
{
    Q_OBJECT

public:
    VideoWidget(QWidget *parent = 0);

protected:
    void keyPressEvent(QKeyEvent *event);
    void mouseDoubleClickEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);

};




class videoWidget : public QDockWidget , Ui::videoWidget {
    Q_OBJECT
public:

    VideoWidget *videoW;
    QMediaPlayer *player;
    QTimer *imageTimer;
    videoWidget(QObject *parent);
    ~videoWidget();
    QMediaPlaylist *playlist;
        ImageWindow *mjpegImage;
    timeConsumingThread *otherThread;
    public slots:
    void clickedPlay();
    void clickedStop();
    void requestImage();
    void run_thread();
    void displayImage(const QPixmap &);
private:
QNetworkAccessManager *netImageHttp;
public slots:
    void netImageHttpFinished(QNetworkReply* reply);
    

};



#endif // VIDEOWIDGET_H
